﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics; // cho cau lenh process o duoi
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;

namespace Immo_Rale.ShowForm.Biens
{
    public partial class Contrat : Form
    {
        public Contrat()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            PdfDocument pdf = new PdfDocument();
            pdf.Info.Title = "Contrat";
            PdfPage pdfPage = pdf.AddPage();
            XGraphics graph = XGraphics.FromPdfPage(pdfPage);
            XFont font = new XFont("Verdana", 20, XFontStyle.Bold);
            int yPoint = 0;
            graph.DrawString("This is my first PDF document", font, XBrushes.Black, new XRect(0, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopCenter);
            yPoint += 40;
            graph.DrawString("This is second line", font, XBrushes.Black, new XRect(0, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopCenter);
            string pdfFilename = ".\\Contrat\\firstpage.pdf";
            pdf.Save(pdfFilename);
            Process.Start(pdfFilename);
            this.Close();
        }
    }
}
